import React, { useState } from 'react'
import style from './style.module.css'
import {
    Form,
    Input,
} from 'antd';


export default function SencedKill(props) {
    // 传过来的值
    let { addTitle, addContent, addOriginal, addConfiguration } = props

    // 父传子 传过来的图片
    let { uploadUrlList } = props
    // 配置
    const [valueConfiguration, setValueConfiguration] = useState('')
    // 标题
    const [valueTitle, setVlaueTitle] = useState('');
    // 简介
    const [valueContent, setValueContent] = useState('');
    // 单位
    const [valueOriginal, setValueOriginal] = useState('')
    // 配置
    const handleConfiguration = (e) => {
        setValueConfiguration(e.target.value)
        addConfiguration(e.target.value)
    }
    // 标题
    const handleTitle = (e) => {
        setVlaueTitle(e.target.value)
        addTitle(e.target.value)
    }
    // 简介
    const handleContent = (e) => {
        setValueContent(e.target.value)
        addContent(e.target.value)
    }
    // 单位
    const handleOriginal = (e) => {
        console.log(e);
        setValueOriginal(e.target.value)
        addOriginal(e.target.value)
    }

    return (
        <div className={style.SencedKillBox}>
            <Form
                name="basic"
                autoComplete="off"
                style={{ width: 300 }}
            >
                <Form.Item
                    name='img'
                    label='商品图片'>
                    <img src={uploadUrlList} alt="" />
                </Form.Item>
                <Form.Item
                    label="配置"
                    name="configuration"
                >
                    <Input onChange={handleConfiguration} value={valueConfiguration} />
                </Form.Item>
                <Form.Item
                    label="秒杀标题"
                    name="title"
                >
                    <Input onChange={handleTitle} value={valueTitle} />
                </Form.Item>
                <Form.Item
                    label="秒杀活动简介"
                    name="content"
                >
                    <Input onChange={handleContent} value={valueContent} />
                </Form.Item>
                <Form.Item
                    label="单位"
                    name="original"
                >
                    <Input onChange={handleOriginal} value={valueOriginal} />
                </Form.Item>
            </Form>
        </div>
    )
}
